import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
import { JVxeTypes } from '/@/components/jeecg/JVxeTable/types';

//列表数据
export const columns: BasicColumn[] = [
  // {
  //   title: '照片列表',
  //   dataIndex: 'brandId_dictText',
  //   width: 180,
  //   slots: { customRender: 'imgs' },
  // },
  {
    title: '卡种ID',
    align: 'center',
    dataIndex: 'id',
    resizable: true,
    slots: { customRender: 'ID' },
  },
  {
    title: '卡种名称',
    align: 'center',
    dataIndex: 'name',
    resizable: true,
  },
  {
    title: '渠道来源',
    align: 'center',
    dataIndex: 'cardSourceId_dictText',
    resizable: true,
  },
  {
    title: '类型',
    align: 'center',
    dataIndex: 'cardStyleId_dictText',
    resizable: true,
  },
  {
    title: '未售出',
    align: 'center',
    dataIndex: 'unsold',
    resizable: true,
  },
  {
    title: '库存成本',
    align: 'center',
    dataIndex: 'cost',
    resizable: true,
  },
  {
    title: '显隐/排序',
    dataIndex: 'brandId_dictText',
    width: 180,
    slots: { customRender: 'isShow' },
    resizable: true,
  },

  {
    title: '自动发货/关键词',
    dataIndex: 'keyword',
    width: 180,
    slots: { customRender: 'keyword' },
    resizable: true,
  },

  {
    title: '失效时间',
    align: 'center',
    dataIndex: 'lifespan',
    resizable: true,
  },
  {
    title: '创建时间',
    align: 'center',
    dataIndex: 'createTime',
    resizable: true,
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '品牌',
    field: 'brandId',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_brand,name,id',
      placeholder: '请选择品牌',
      showSearch: true,
    },
  },

  {
    label: '渠道来源',
    field: 'cardSourceId',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_card_source,name,id',
    },
  },
  {
    field: 'createTime',
    label: '失效时间',
    component: 'RangePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    label: '类型',
    field: 'cardStyleId',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_card_style,name,id',
    },
  },
  {
    label: '类别',
    field: 'oneId',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_category_one,name,id',
    },
  },
  {
    label: '是否商品编码匹配',
    field: 'isCode',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'yn',
    },
  },
  {
    label: '是否关键词匹配',
    field: 'isMatch',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'yn',
    },
  },
  {
    label: '关键词',
    field: 'keyword',
    component: 'Input',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '卡种名称',
    field: 'name',
    component: 'Input',
    // dynamicRules: ({ model, schema }) => {
    //   return [{ required: true, message: '请输入卡种名称!' }];
    // },
  },
  {
    label: '渠道来源',
    field: 'cardSourceId',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_card_source,name,id',
    },
  },
  {
    label: '卡种类型',
    field: 'cardStyleId',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_card_style,name,id',
    },
  },
  {
    label: '所属品牌',
    field: 'brandId',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'app_brand,name,id',
      showSearch: true,
    },
  },
  {
    label: '是否需要查门店',
    field: 'isQueryStores',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'yn',
    },
  },
  {
    label: '折扣比',
    field: 'discount',
    component: 'Input',
    slot: 'Discount',
    ifShow: ({ values }) => {
      return values.cardStyleId === '1901810798635651073';
    },
  },
  {
    label: '卡种标签',
    field: 'cardTypeLabel',
    component: 'Input',
    slot: 'CardTypeLabel',
    ifShow: ({ values }) => {
      return values.cardStyleId === '1901810798635651073';
    },
  },
  {
    label: '收购价',
    field: 'buyPrice',
    component: 'InputNumber',

    colProps: { span: 10 },
    ifShow: ({ values }) => {
      return values.cardStyleId !== '1901810798635651073';
    },
  },
  {
    label: '调账',
    field: 'accountPrice',
    component: 'InputNumber',

    colProps: { span: 10 },
    ifShow: ({ values }) => {
      return values.cardStyleId !== '1901810798635651073';
    },
  },
  {
    label: '售价',
    field: 'sellPrice',
    component: 'InputNumber',

    colProps: { span: 10 },
    ifShow: ({ values }) => {
      return values.cardStyleId !== '1901810798635651073';
    },
  },
  {
    label: '划线价',
    field: 'underlinePrice',
    component: 'InputNumber',

    colProps: { span: 10 },
    ifShow: ({ values }) => {
      return values.cardStyleId !== '1901810798635651073';
    },
  },

  {
    label: '补贴',
    field: 'subsidy',
    component: 'InputNumber',

    colProps: { span: 10 },
    ifShow: ({ values }) => {
      return values.cardStyleId !== '1901810798635651073';
    },
  },
  {
    label: '学生补贴',
    field: 'studentSubsidy',
    component: 'InputNumber',

    colProps: { span: 10 },
    ifShow: ({ values }) => {
      return values.cardStyleId !== '1901810798635651073';
    },
  },
  {
    label: '上级补贴',
    field: 'managerSubsidy',
    component: 'InputNumber',

    colProps: { span: 10 },
    ifShow: ({ values }) => {
      return values.cardStyleId !== '1901810798635651073';
    },
  },

  {
    label: '上上级补贴',
    field: 'superiorSubsidy',
    component: 'InputNumber',

    colProps: { span: 10 },
    ifShow: ({ values }) => {
      return values.cardStyleId !== '1901810798635651073';
    },
  },
  // {
  //   label: '有限期不低于（天）',
  //   field: 'sellPrice',
  //   component: 'InputNumber',
  // },
  {
    label: '失效时间',
    field: 'lifespan',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    ifShow: ({ values }) => {
      return values.cardStyleId !== '1901810798635651073';
    },
  },

  {
    label: '上传方式',
    field: 'uploadType',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'card_upload_type',
    },
    ifShow: ({ values }) => {
      return values.cardStyleId !== '1901810798635651073';
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
    //属性
    componentProps: {
      //可以点击清除图标删除内容
      allowClear: true,
      //是否展示字数
      showCount: true,
      //自适应内容高度，可设置为 true | false 或对象：{ minRows: 2, maxRows: 6 }
      autoSize: {
        //最小显示行数
        minRows: 2,
        //最大显示行数
        maxRows: 3,
      },
    },
  },

  {
    label: '上传图片',
    field: 'image',
    component: 'JImageUpload',
    componentProps: {
      fileMax: 1,
    },
    // dynamicRules: ({ model, schema }) => {
    //   return [{ required: true, message: '只能上传jpg/png文件，且不超过500kb!' }];
    // },
  },
  {
    label: '使用规则',
    field: 'remarks',
    component: 'JEditor',
  },
  // {
  //   label: '来源提醒',
  //   field: 'stores',
  //   component: 'JEditor',
  // },
  // {
  //   label: '寄售须知',
  //   field: 'stores',
  //   component: 'JEditor',
  // },
  {
    label: '适用门店',
    field: 'stores',
    component: 'InputTextArea',
    //属性
    componentProps: {
      //可以点击清除图标删除内容
      allowClear: true,
      //是否展示字数
      showCount: true,
      //自适应内容高度，可设置为 true | false 或对象：{ minRows: 2, maxRows: 6 }
      autoSize: {
        //最小显示行数
        minRows: 2,
        //最大显示行数
        maxRows: 3,
      },
    },
  },
];

// 创建会员
export const formSchema2: FormSchema[] = [
  {
    label: '卡种名称',
    field: 'name',
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '卡种标签',
    field: 'cardTypeLabel',
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '所属会员',
    field: 'memberId',
    component: 'JDictSelectTag',
    slot: 'User',
  },
  {
    label: '折扣比',
    field: 'discount',
    component: 'Input',
    slot: 'Discount',
  },

  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
    //属性
    componentProps: {
      //可以点击清除图标删除内容
      allowClear: true,
      //是否展示字数
      showCount: true,
      //自适应内容高度，可设置为 true | false 或对象：{ minRows: 2, maxRows: 6 }
      autoSize: {
        //最小显示行数
        minRows: 2,
        //最大显示行数
        maxRows: 3,
      },
    },
  },
];

// 高级查询数据
export const superQuerySchema = {
  brandId: { title: '品牌', order: 0, view: 'list', type: 'string', dictTable: 'app_brand', dictCode: 'id', dictText: 'name' },
  name: { title: '卡种名称', order: 1, view: 'text', type: 'string' },
  image: { title: '卡种log', order: 2, view: 'image', type: 'string' },
  sellPrice: { title: '售卖价', order: 3, view: 'number', type: 'number' },
  buyPrice: { title: '回收价', order: 4, view: 'number', type: 'number' },
  underlinePrice: { title: '划线价', order: 5, view: 'number', type: 'number' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
